/** 
 * 编制模型
*/
<template>
    <vp-dialog ref="dialogRef">    
        <template #title>
            <vp-label zh="编制模型" en="Edit Modeler" align="left"/>
        </template>
        <ModelerCanvas ref="modelerCanvasRef" @form-submited="handleFormSubmited" :id="bpmn.id" :name="bpmn.name" :style="`height:calc(100vh - 250px)`"></ModelerCanvas>
        <template #footer>
            <vp-btn type="primary" @click="modelerCanvasRef.handleDownloadBpmnXml()"><vp-label zh="下载" en="Download"/></vp-btn>
            <vp-btn-confirm @click="modelerCanvasRef.handleSaveBpmnXml()"/>
        </template>
    </vp-dialog>
</template>

<script lang="ts">
export default {
    name: 'EditWorkflowmodel',
};
</script>

<script lang="ts" setup>
import { defineExpose, ref } from 'vue'

import ModelerCanvas from './ModelerCanvas.vue';

const emits = defineEmits<{
    (e: 'formSubmited'): void
}>()

const dialogRef = ref();

//模型信息
const bpmn = ref<{
    id: string,
    name: string,
}>({
    id: "",
    name: ""
})

const modelerCanvasRef = ref();

const handleOpen = (id: string, name: string)=>{
    bpmn.value = {
        id: id,
        name: name,
    }
    dialogRef.value.handleOpen()
}

//保存模型后事件
const handleFormSubmited = ()=>{ 
    emits('formSubmited')
    dialogRef.value.handleClose()
}

defineExpose({
    handleOpen
})
</script>
<style scoped lang="scss">

</style>
